import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Endstart
 * Date: 2021-04-19
 * Time: 21:10
 */
public class myCode1 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String instr1 = scanner.nextLine();
        String instr2 = scanner.nextLine();
        String instr3 = scanner.nextLine();

        int length = solution(instr1, instr2, instr3);
        System.out.println(length);
    }

    private static int solution(String instr1, String instr2, String instr3) {
        String tmp = instr1 + instr2;
        if (tmp.contains(instr3)) {
            return tmp.length();
        }

        String outStr = instr3;
        String subPrefix = "";
        int index = 0;
        for (index = outStr.length(); index > 0; index--) {
            subPrefix = outStr.substring(0, index);
            if (instr1.endsWith(subPrefix)) {
                break;
            }
        }
        String subSuffix = "";
        outStr = outStr.substring(index);
        for (index = 0; index < outStr.length(); index++) {
            subSuffix = outStr.substring(index);
            if (instr2.startsWith(subSuffix)) {
                break;
            }
        }

        outStr = outStr.substring(0, index);
        return instr1.length() + outStr.length() + instr2.length();

    }

}
